package com.huawei;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Description: HJ86 求最大连续bit数
 *
 * @author weiruibai.vendor
 * Date: 2022/9/3 21:40
 */
public class HJ86 {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        Integer num = Integer.parseInt(br.readLine());
        if (num == 0) {
            System.out.println(0);
            return;
        }
        int ans = 0;
        boolean start = false;
        int tmpAns = 0;
        for (int i = 0; i < 32; i++) {
            int and = (num & (1 << i));
            if (and != 0 && !start) {// 上一个是0
                start = true;
                tmpAns = 1;
            } else if (and != 0 && start) {// 上一个是1,现在也是1
                tmpAns++;
            } else if (and == 0 && start) { // 上一个是1，现在是0
                ans = Math.max(tmpAns, ans);
                start = false;
                tmpAns = 0;// 还原
            } else {// 一直是0

            }
        }
        ans = Math.max(ans, tmpAns);
        System.out.println(ans);
    }
}
